package com.eltsistemas.dao;

import org.hibernate.Query;
import org.hibernate.Session;

public class SalarialDao {
	
	private Session session;
	
	public SalarialDao(Session session)
	{
		this.session=session;
	}
	
	public Long id_atualSalarial(Long id_Funcionario)
	{
		StringBuilder consulta = new StringBuilder();
		consulta.append("SELECT MAX(sal.id) from Salarial as sal WHERE ");
		consulta.append("sal.funcionario.id = :id_funcionario and sal.status_Atual= :status");
		
		Query query = this.session.createQuery(consulta.toString());
		query.setLong("id_funcionario", id_Funcionario);
		query.setBoolean("status", true);
		
		Long id_AtualSalarial = (Long) query.uniqueResult();
		
		return id_AtualSalarial;
	}
}
